--- title: "L1-020 帅到没朋友" created: 2025-11-28 tags: - 算法 --- # L1-020 帅到没朋友 ## 题目 [L1-020 帅到没朋友](https://pintia.cn/problem-sets/994805046380707840/exam/problems/type/7?problemSetProblemId=994805117167976448&page=0) ![[image-e5c0084e.png]] ## 思路分析 ## 代码实现 ```cpp #include using namespace std; const int N = 1e5 + 10; int arr[N] = {0}; //初始化每个人都没有朋友 0表示没朋友,1表示有朋 int main(){ int n,m,x; cin >> n; for(int i = 0; i < n; i ++){ int k; cin >> k; if(k == 1) cin >> x; else{ while(k --){ cin >> x; arr[x] = 1; } } } int flag = 0; cin >> m; while(m --){ cin >> x; if(arr[x] == 0 && flag == 0) printf("%05d",x), flag = 1; else if(arr[x] == 0) printf(" %05d",x); arr[x] = 1; } if(flag == 0) cout << "No one is handsome"; return 0; } ``` ## 同类题型 ## 视频讲解 --- ⬅️ [[L1-019 谁先倒|L1-019 谁先倒]] 🏠 [[00-天梯赛]] ➡️ [[L1-021 重要的话说三遍|L1-021 重要的话说三遍]]